package com.hxzy.config;

import com.hxzy.comm.Constants;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author wy
 * @Description TODO
 * @Date 2023/5/25 14:33
 * @Version 1.0
 */
@Configuration
public class FanoutExchangeConfig {

    @Bean
    public Queue demoQeueu(){
        Queue  queue=new Queue(Constants.QUEUE_DEMO);
        return queue;
    }

    @Bean
    public Queue testQeueu(){
        Queue  queue=new Queue(Constants.QUEUE_TEST);
        return queue;
    }

    @Bean
    public FanoutExchange  demoFanoutExchange(){
        FanoutExchange  fanoutExchange=new FanoutExchange(Constants.FANOUT_EXCHNAGE_DEMO);
        return fanoutExchange;
    }


    @Bean
    public Binding  binding01(FanoutExchange  demoFanoutExchange,Queue demoQeueu){
        return BindingBuilder.bind(demoQeueu).to(demoFanoutExchange);
    }

    @Bean
    public Binding  binding02(FanoutExchange  demoFanoutExchange,Queue testQeueu){
        return BindingBuilder.bind(testQeueu).to(demoFanoutExchange);
    }
}
